<template>
	<div>
		<el-row class="bg-top">
			<h3 class="baseHeader" style="text-align: left">开门速度写入</h3>
			<el-col :span="16">
				<div class="leftBox">
					<div class="chart" id="chart1"></div>
				</div>
			</el-col>
			<el-col :span="8">
				<div class="rightBox">
					<el-form :model="baseForm1" :rules="dataRule1" ref="baseForm1" style="display: flex">
						<!-- <div class="leftcontent">
              <el-form-item prop="openDoorSpeed1">
                <el-input v-model="baseForm1.openDoorSpeed1"
                  oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
                  :disabled="true" placeholder="开门时间"></el-input>
              </el-form-item>
              <el-form-item prop="openDoorSpeed2">
                <el-input v-model="baseForm1.openDoorSpeed2"
                  oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
                  :disabled="openWriteStatus" placeholder="加速段末端速度"></el-input>
              </el-form-item>
              <el-form-item prop="openDoorSpeed3">
                <el-input v-model="baseForm1.openDoorSpeed3"
                  oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
                  :disabled="openWriteStatus" placeholder="匀速段速度"></el-input>
              </el-form-item>
              <el-form-item prop="openDoorSpeed4">
                <el-input v-model="baseForm1.openDoorSpeed4"
                  oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
                  :disabled="openWriteStatus" placeholder="减速段末端速度"></el-input>
              </el-form-item>
              <el-form-item prop="openDoorSpeed5">
                <el-input v-model="baseForm1.openDoorSpeed5"
                  oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
                  :disabled="openWriteStatus" placeholder="慢速段速度"></el-input>
              </el-form-item>
              <div style="
                                width: 100%;
                                display: flex;
                                justify-content: space-between;
                                margin-top: 10px;
                              ">
                <el-button type="primary" @click="openSaveDCU()">保存
                </el-button>
              </div>
            </div> -->
						<div class="leftcontent leftcontent1">
							<el-form-item class="selectDoor" prop="dcu" label="门控单元编号">
								<el-select v-model="baseForm1.dcuId" placeholder="请选择" @change="getdoorChange">
									<!-- <el-checkbox
                    v-model="checkOptions.checkAll"
                    :style="{ paddingLeft: '20px' }"
                    :indeterminate="checkOptions.isIndeterminate"
                    @change="handleCheckAllChange"
                  >
                    全部
                  </el-checkbox> -->
									<el-option v-for="(item, index) in options2" :key="index" :label="item.dcu"
										:value="item.dcu"></el-option>
								</el-select>
							</el-form-item>
							<!-- <el-form-item class="selectDoor" prop="" label="开门速度选择">
                <el-select v-model="doorQx" placeholder="请选择">
                  <el-option v-for="item in SpeedOptions" :key="item.value" :label="item.label"
                    :value="item.value"></el-option>
                </el-select>
              </el-form-item> -->
							<div style="
	                                width: 100%;
	                                display: flex;
	                              ">
								<!-- <el-button type="primary" @click="echartsQX()">生成曲线
                </el-button> -->
								<form name="formInput">
									<input type="file" id="fileDemo" class="input"
										style="position:absolute; clip:rect(0 0 0 0);" @change="readInputFile">
								</form>
								<el-button type="primary" onclick="document.formInput.fileDemo.click()">
									加载
								</el-button>
								<!-- <input type="file" id="datafile" @change="readInputFile" /> -->
								<el-button type="primary" @click="writeOpendSpeed()">写入
								</el-button>
							</div>
						</div>
					</el-form>
				</div>
			</el-col>
		</el-row>
		<el-row class="bg-bottom">
			<h3 class="baseHeader" style="text-align: left">关门速度写入</h3>
			<el-col :span="16">
				<div class="leftBox">
					<div class="chart" id="chart2"></div>
				</div>
			</el-col>
			<el-col :span="8">
				<div class="rightBox">
					<el-form :model="baseForm2" :rules="dataRule2" ref="baseForm2" style="display: flex">
						<!-- <div class="leftcontent">
							<el-form-item prop="closeDoorSpeed1">
								<el-input v-model="baseForm2.closeDoorSpeed1"
									oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
									:disabled="true" placeholder="关门时间"></el-input>
							</el-form-item>
							<el-form-item prop="closeDoorSpeed2">
								<el-input v-model="baseForm2.closeDoorSpeed2"
									oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
									:disabled="closeWriteStatus" placeholder="加速段末端速度"></el-input>
							</el-form-item>
							<el-form-item prop="closeDoorSpeed3">
								<el-input v-model="baseForm2.closeDoorSpeed3"
									oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
									:disabled="closeWriteStatus" placeholder="匀速段速度"></el-input>
							</el-form-item>
							<el-form-item prop="closeDoorSpeed4">
								<el-input v-model="baseForm2.closeDoorSpeed4"
									oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
									:disabled="closeWriteStatus" placeholder="减速段末端速度"></el-input>
							</el-form-item>
							<el-form-item prop="closeDoorSpeed5">
								<el-input v-model="baseForm2.closeDoorSpeed5"
									oninput="
                    this.value=this.value.replace(/\D*(\d*)(\.?)(\d{0,1})\d*/,'$1$2$3').replace(/^0+(\d)/, '$1') .replace(/^\./, '0.') .match(/^\d*(\.?\d{0,1})/g)[0] || '' "
									:disabled="closeWriteStatus" placeholder="慢速段速度"></el-input>
							</el-form-item>
							<div style="
                                width: 100%;
                                display: flex;
                                justify-content: space-between;
                                margin-top: 10px;
                              ">
								<el-button type="primary" @click="closeSaveDCU()">保存
								</el-button>
							</div>
						</div> -->
						<div class="leftcontent leftcontent1">
							<el-form-item class="selectDoor" prop="dcu" label="门控单元编号">
								<el-select v-model="baseForm2.dcuId" placeholder="请选择" @change="getdoorChange1">
									<!-- <el-checkbox
                    v-model="checkOptions1.checkAll"
                    :style="{ paddingLeft: '20px' }"
                    :indeterminate="checkOptions1.isIndeterminate"
                    @change="handleCheckAllChange1"
                  >
                    全部
                  </el-checkbox> -->
									<el-option v-for="(item, index) in options2" :key="index" :label="item.dcu"
										:value="item.dcu"></el-option>
								</el-select>
							</el-form-item>
							<!-- <el-form-item class="selectDoor" prop="" label="关门速度选择">
								<el-select v-model="doorQx" placeholder="请选择">
									<el-option v-for="item in SpeedOptions" :key="item.value" :label="item.label"
										:value="item.value"></el-option>
								</el-select>
							</el-form-item> -->
							<div style="
	                                width: 100%;
	                                display: flex;
	                              ">
								<!-- <el-button type="primary" @click="echartsQX1()">生成曲线
								</el-button> -->
								<form name="formInput1">
									<input type="file" id="fileDemo1" class="input"
										style="position:absolute; clip:rect(0 0 0 0);" @change="readInputFile1">
								</form>
								<el-button type="primary" onclick="document.formInput1.fileDemo1.click()">
									加载
								</el-button>
								<el-button type="primary" @click="writeCloseSpeed()">写入
								</el-button>
							</div>
						</div>
					</el-form>
				</div>
			</el-col>
		</el-row>
		<el-dialog :visible.sync="openSaveVisible" title="开门速度曲线保存" :close-on-click-modal="false"
			:close-on-press-escape="false">
			<el-form :model="openSaveForm" ref="openSaveForm" :rules="openSaveFormRule" @keyup.enter.native="confirm()"
				label-width="200px">
				<el-form-item prop="name" label="开门速度曲线保存名称">
					<el-input v-model="openSaveForm.name" placeholder="开门速度曲线保存名称"></el-input>
				</el-form-item>
			</el-form>
			<template slot="footer">
				<el-button @click="openSaveVisible = false">{{
					$t("cancel")
				}}</el-button>
				<el-button type="primary" @click="confirm()">{{
					$t("confirm")
				}}</el-button>
			</template>
		</el-dialog>
		<el-dialog :visible.sync="closeSaveVisible" title="关门速度曲线保存" :close-on-click-modal="false"
			:close-on-press-escape="false">
			<el-form :model="closeSaveForm" ref="closeSaveForm" :rules="closeSaveFormRule" @keyup.enter.native="confirm1()"
				label-width="200px">
				<el-form-item prop="name" label="关门速度曲线保存名称">
					<el-input v-model="closeSaveForm.name" placeholder="关门速度曲线保存名称"></el-input>
				</el-form-item>
			</el-form>
			<template slot="footer">
				<el-button @click="closeSaveVisible = false">{{
					$t("cancel")
				}}</el-button>
				<el-button type="primary" @click="confirm1()">{{
					$t("confirm")
				}}</el-button>
			</template>
		</el-dialog>
	</div>
</template>
<script>
import debounce from "lodash/debounce";
import utils from "@/utils/utils";
export default {
	data() {
		this.curveChart1 = null;
		this.curveChart2 = null;
		return {
			baseForm1: {
				openDoorSpeed1: "",
				openDoorSpeed2: "",
				openDoorSpeed3: "",
				openDoorSpeed4: "",
				openDoorSpeed5: "",
				dcuId: '广播',
			},
			baseForm2: {
				closeDoorSpeed1: "",
				closeDoorSpeed2: "",
				closeDoorSpeed3: "",
				closeDoorSpeed4: "",
				closeDoorSpeed5: "",
				dcuId: '广播',
			},
			openDoorSpeed: [],
			openDoorSpeedX: [],
			closeDoorSpeed: [],
			closeDoorSpeedX: [],
			options: utils.cpuType,
			options2: [],
			openDoorOption: null,
			closeDoorOption: null,
			openWriteStatus: true,
			closeWriteStatus: true,
			checkOptions: {
				isIndeterminate: false,
				checkAll: false,
			},
			checkOptions1: {
				isIndeterminate: false,
				checkAll: false,
			},
			SpeedOptions: [],
			doorQx: "",
			openSaveVisible: false,
			closeSaveVisible: false,
			openSaveForm: {
				name: "",
			},
			closeSaveForm: {
				name: "",
			},
			dcuId1: '',
			dcuId2: '',
		};
	},
	computed: {
		dataRule1() {
			return {
				// openDoorSpeed1: [
				//   {
				//     required: true,
				//     message: "开门时间不能为空",
				//     trigger: "blur",
				//   },
				// ],
				openDoorSpeed2: [{
					required: true,
					message: "加速段末端速度不能为空",
					trigger: "blur",
				},],
				openDoorSpeed3: [{
					required: true,
					message: "匀速段速度不能为空",
					trigger: "blur",
				},],
				openDoorSpeed4: [{
					required: true,
					message: "减速段末端速度不能为空",
					trigger: "blur",
				},],
				openDoorSpeed5: [{
					required: true,
					message: "慢速段速度不能为空",
					trigger: "blur",
				},],
				dcuId: [{
					required: true,
					message: "门控编号不能为空",
					trigger: "blur",
				},],
			};
		},
		dataRule2() {
			return {
				// closeDoorSpeed1: [
				//   {
				//     required: true,
				//     message: "关门时间不能为空",
				//     trigger: "blur",
				//   },
				// ],
				closeDoorSpeed2: [{
					required: true,
					message: "加速段末端速度不能为空",
					trigger: "blur",
				},],
				closeDoorSpeed3: [{
					required: true,
					message: "匀速段速度不能为空",
					trigger: "blur",
				},],
				closeDoorSpeed4: [{
					required: true,
					message: "减速段末端速度不能为空",
					trigger: "blur",
				},],
				closeDoorSpeed5: [{
					required: true,
					message: "慢速段速度不能为空",
					trigger: "blur",
				},],
				dcuId: [{
					required: true,
					message: "门控编号不能为空",
					trigger: "blur",
				},],
			};
		},
		openSaveFormRule() {
			return {
				name: [{
					required: true,
					message: "开门速度曲线名字不能为空",
					trigger: "blur",
				},],
			};
		},
		closeSaveFormRule() {
			return {
				name: [{
					required: true,
					message: "关门速度曲线名字不能为空",
					trigger: "blur",
				},],
			};
		},
	},
	watch: {
		"baseForm1.dcuId": {
			handler(val) {
				if (this.baseForm1.dcuId == '广播') {
					this.dcuId1 = 0
				}
				if (val.length !== 0) {
					this.openWriteStatus = false;
				}
			},
			deep: true,
			immediate: true,
		},
		"baseForm2.dcuId": {
			handler(val) {
				if (this.baseForm2.dcuId == '广播') {
					this.dcuId2 = 0
				}
				if (val.length !== 0) {
					this.closeWriteStatus = false;
				}
			},
			deep: true,
			immediate: true,
		},
	},
	mounted() {
		this.getdoorList();
		this.initEcharts1();
		this.initEcharts2();
	},
	beforeDestroy() {
		this.curveChart1.dispose();
		this.curveChart2.dispose();
		this.curveChart1 = null;
		this.curveChart2 = null;
	},
	methods: {
		//加载本地文件
		readInputFile(event) {
			// debugger
			let file = event.target.files[0];
			if (!file) {
				return;
			}
			let reader = new FileReader();
			reader.addEventListener('load', event => {
				let content = event.target.result;
				alert(content);
			});
			reader.readAsText(file);
		},
		readInputFile1(event) {
			// debugger
			let file = event.target.files[0];
			if (!file) {
				return;
			}
			let reader = new FileReader();
			reader.addEventListener('load', event => {
				let content = event.target.result;
				alert(content);
			});
			reader.readAsText(file);
		},
		// 生成曲线
		echartsQX() {
			// this.dataRule1.openDoorSpeed1[0].required = false;
			this.dataRule1.dcuId.required = false;
			this.$refs["baseForm1"].validate((valid) => {
				if (!valid) {
					return false;
				}
				let obj = {
					// cpuType: this.dataForm.openDoor.cpuId,
					// dcuArr: !this.checkOptions.isIndeterminate ? [] : this.dataForm.openDoor.dcu,
					// speedArr: this.openDoorSpeed
					// doorTime: this.baseForm1.openDoorSpeed2,
					accelerationEndSpeed: this.baseForm1.openDoorSpeed2,
					uniformSpeed: this.baseForm1.openDoorSpeed3,
					decelerationEndSpeed: this.baseForm1.openDoorSpeed4,
					slowSpeed: this.baseForm1.openDoorSpeed5,
				};
				this.$http
					.post("/psc/dcu/generateCurve", obj)
					.then((res) => {
						if (res.data.code !== 0) {
							return this.$message.error(res.data.msg);
						}
						this.$message({
							message: this.$t("prompt.success"),
							type: "success",
							duration: 500,
						});
						var dataX = 0;
						this.openDoorSpeedX = [0];
						for (var i = 0; i < res.data.data.length; i++) {
							dataX = this.commonAdd(dataX, res.data.data[i].time);
							this.openDoorSpeedX.push(dataX);
						}
						this.baseForm1.openDoorSpeed1 =
							this.openDoorSpeedX[this.openDoorSpeedX.length - 1].toFixed(1);
						this.openDoorSpeed = [];
						for (let item in this.baseForm1) {
							this.openDoorSpeed.push(Number(this.baseForm1[item]));
						}
						this.openDoorSpeed.splice(0, 1);
						this.openDoorSpeed.unshift(0);
						this.curveChart1.clear();
						this.curveChart1.setOption(this.openDoorOption);
						this.initEcharts1();
					})
					.catch(() => { });
			});
		},
		commonAdd(number1, number2) {
			let result = 0;
			if (Number.isInteger(number1) || Number.isInteger(number2)) {
				result = number1 + number2;
			} else {
				//两个都是纯小数
				const number1Array = number1.toString().split(".");
				const number2Array = number2.toString().split(".");
				//最大的除数位数
				let maxBit = 1;
				if (number1Array[1].length >= number2Array[1].length) {
					maxBit = number1Array[1].length + 1;
				} else {
					maxBit = number2Array[1].length + 1;
				}
				const divisor = parseInt("1".padEnd(maxBit, 0));
				result = (number1 * divisor + number2 * divisor) / divisor;
			}
			return result;
		},
		echartsQX1() {
			this.dataRule2.closeDoorSpeed1[0].required = false;
			this.dataRule2.dcuId.required = false;
			this.$refs["baseForm2"].validate((valid) => {
				if (!valid) {
					return false;
				}
				let obj = {
					// cpuType: this.dataForm.openDoor.cpuId,
					// dcuArr: !this.checkOptions.isIndeterminate ? [] : this.dataForm.openDoor.dcu,
					// speedArr: this.openDoorSpeed
					// doorTime: this.baseForm2.closeDoorSpeed1,
					accelerationEndSpeed: this.baseForm2.closeDoorSpeed2,
					uniformSpeed: this.baseForm2.closeDoorSpeed3,
					decelerationEndSpeed: this.baseForm2.closeDoorSpeed4,
					slowSpeed: this.baseForm2.closeDoorSpeed5,
				};
				this.$http
					.post("/psc/dcu/generateCurve", obj)
					.then((res) => {
						if (res.data.code !== 0) {
							return this.$message.error(res.data.msg);
						}
						this.$message({
							message: this.$t("prompt.success"),
							type: "success",
							duration: 500,
						});
						var dataX = 0;
						this.closeDoorSpeedX = [0];
						for (var i = 0; i < res.data.data.length; i++) {
							// dataX += res.data.data[i].time
							dataX = this.commonAdd(dataX, res.data.data[i].time);
							this.closeDoorSpeedX.push(dataX);
						}
						this.baseForm2.closeDoorSpeed1 =
							this.closeDoorSpeedX[this.closeDoorSpeedX.length - 1].toFixed(1);
						this.closeDoorSpeed = [];
						for (let item in this.baseForm2) {
							this.closeDoorSpeed.push(Number(this.baseForm2[item]));
						}
						this.closeDoorSpeed.splice(0, 1);
						this.closeDoorSpeed.unshift(0);
						this.curveChart2.clear();
						this.curveChart2.setOption(this.closeDoorOption);
						this.initEcharts2();
					})
					.catch(() => { });
			});
		},
		// 流向全选
		handleCheckAllChange(e) {
			if (e) {
				this.baseForm1.dcuId = 0;
				this.checkOptions1.isIndeterminate = true;
			}
		},
		getdoorChange(val) {
			if (val == '广播') {
				this.dcuId1 = 0
			} else {
				let v = Number(val);
				if (v > 200) {
					this.dcuId1 = v - 200;
				} else if (v > 100 && v < 200) {
					this.dcuId1 = v + 28;
				}
				this.$forceUpdate();
			}

		},
		// 流向全选
		handleCheckAllChange1(e) {
			if (e) {
				this.baseForm2.dcuId = 0;
				this.checkOptions2.isIndeterminate = true;
			}
		},
		getdoorChange1(val) {
			if (val == '广播') {
				this.dcuId2 = 0
			} else {
				let v = Number(val);
				if (v > 200) {
					this.dcuId2 = v - 200;
				} else if (v > 100 && v < 200) {
					this.dcuId2 = v + 28;
				}
				this.$forceUpdate();
			}

		},
		writeOpendSpeed: debounce(
			function () {
				// this.dataRule1.openDoorSpeed1[0].required = true;
				this.dataRule1.dcuId.required = true;
				this.$refs["baseForm1"].validate((valid) => {
					if (!valid) {
						return false;
					}
					this.openDoorSpeed = [];
					for (let item in this.baseForm1) {
						this.openDoorSpeed.push(Number(this.baseForm1[item]));
					}
					this.curveChart1.clear();
					this.curveChart1.setOption(this.openDoorOption);
					let obj = {
						dcuId: this.dcuId1,
						// speedArr: this.openDoorSpeed
						doorTime: this.baseForm1.openDoorSpeed1,
						accelerationEndSpeed: this.baseForm1.openDoorSpeed2,
						uniformSpeed: this.baseForm1.openDoorSpeed3,
						decelerationEndSpeed: this.baseForm1.openDoorSpeed4,
						slowSpeed: this.baseForm1.openDoorSpeed5,
					};
					this.$http
						.post("/psc/dcu/writeOpenCurve", obj)
						.then((res) => {
							if (res.data.code !== 0) {
								return this.$message.error(res.data.msg);
							}
							this.$message({
								message: this.$t("prompt.success"),
								type: "success",
								duration: 500,
							});
						})
						.catch(() => { });
				});
			},
			1000, {
			leading: true,
			trailing: false,
		}
		),
		writeCloseSpeed: debounce(
			function () {
				this.dataRule2.closeDoorSpeed1[0].required = true;
				this.dataRule2.dcuId.required = true;
				this.$refs["baseForm2"].validate((valid) => {
					if (!valid) {
						return false;
					}
					this.closeDoorSpeed = [];
					for (let item in this.baseForm2) {
						this.closeDoorSpeed.push(Number(this.baseForm2[item]));
					}
					this.curveChart2.clear();
					this.curveChart2.setOption(this.closeDoorOption);
					// debugger;

					let obj = {
						dcuId: this.dcuId2,
						speedArr: this.closeDoorSpeed,
						doorTime: this.baseForm2.closeDoorSpeed1,
						accelerationEndSpeed: this.baseForm2.closeDoorSpeed2,
						uniformSpeed: this.baseForm2.closeDoorSpeed3,
						decelerationEndSpeed: this.baseForm2.closeDoorSpeed4,
						slowSpeed: this.baseForm2.closeDoorSpeed5,
					};
					this.$http
						.post("/psc/dcu/writeCloneCurve", obj)
						.then((res) => {
							if (res.data.code !== 0) {
								return this.$message.error(res.data.msg);
							}
							this.$message({
								message: this.$t("prompt.success"),
								type: "success",
								duration: 500,
							});
						})
						.catch(() => { });
				});
			},
			1000, {
			leading: true,
			trailing: false,
		}
		),
		getdoorList() {
			this.$http.get("/psc/door/getDoor").then((res) => {
				this.options2 = res.data.data.up.concat(res.data.data.down);
				for (var i = 0; i < this.options2.length; i++) {
					if (
						this.options2[i].doorType === 0 ||
						this.options2[i].doorType === 2
					) {
						this.options2.splice(i, 1); // 将使后面的元素依次前移，数组长度减1
						i--; // 如果不减，将漏掉一个元素
					}
				}
				var obj = {
					dcu: '广播',
				}
				this.options2.unshift(obj)
			});
		},
		// 开门速度曲线保存
		openSaveDCU() {
			// this.dataRule1.openDoorSpeed1[0].required = false;
			this.dataRule1.dcuId.required = false;
			this.$refs["baseForm1"].validate((valid) => {
				if (!valid) {
					return false;
				}
				this.openSaveVisible = true;
				this.$nextTick(() => {
					this.$refs["openSaveForm"].resetFields();
				});
			});
		},
		closeSaveDCU() {
			this.dataRule2.closeDoorSpeed1[0].required = false;
			this.dataRule2.dcuId.required = false;
			this.$refs["baseForm2"].validate((valid) => {
				if (!valid) {
					return false;
				}
				this.closeSaveVisible = true;
				this.$nextTick(() => {
					this.$refs["closeSaveForm"].resetFields();
				});
			});
		},
		//保存速度曲线
		confirm() {
			this.$refs["openSaveForm"].validate((valid) => {
				if (!valid) {
					return false;
				}
				//保存数据的接口
			});
		},
		//保存速度曲线
		confirm1() {
			this.$refs["closeSaveForm"].validate((valid) => {
				if (!valid) {
					return false;
				}
				//保存数据的接口
			});
		},
		initEcharts1() {
			this.curveChart1 = this.$echarts.init(document.getElementById("chart1"));
			var that = this;
			var fontColor = "#30eee9";
			this.openDoorOption = {
				backgroundColor: "transparent",
				grid: {
					left: "5%",
					right: "2%",
					top: "10%",
					bottom: "15%",
				},
				tooltip: {
					show: true,
					trigger: "axis",
					axisPointer: {
						type: "shadow",
						lineStyle: {
							color: "#57617B",
						},
					},
				},
				xAxis: {
					type: "category",
					axisLine: {
						show: true,
						lineStyle: {
							color: "#000000",
						},
					},
					axisTick: {
						show: false,
						alignWithLabel: true,
						lineStyle: {
							color: "#000000",
						},
					},
					axisLabel: {
						fontSize: 16,
						show: true,
					},
					boundaryGap: false, // 显示间距设置为false
					data: that.openDoorSpeedX,
				},
				yAxis: {
					name: "速度",
					type: "value",
					min: 0,
					max: Math.max(...this.openDoorSpeed),
					axisLine: {
						show: true,
						lineStyle: {
							color: "#000000",
						},
					},
					splitLine: {
						show: true,
						lineStyle: {
							type: "dotted",
							color: "#000000",
						},
					},
					axisTick: {
						show: true,
					},
					axisLabel: {
						fontSize: 16,
					},
					boundaryGap: ["20%", "20%"],
				},
				series: [{
					name: "",
					type: "line",
					stack: "总量",
					smooth: true,
					symbol: "none",
					showSymbol: false,
					symbolSize: 8,
					lineStyle: {
						color: "#6495ED",
						width: 5,
					},
					markPoint: {
						itemStyle: {
							color: "red",
						},
					},
					data: this.openDoorSpeed,
				},],
			};
			this.curveChart1.setOption(this.openDoorOption);
			window.addEventListener("resize", () => {
				this.curveChart1.resize();
			});
		},
		initEcharts2() {
			this.curveChart2 = this.$echarts.init(document.getElementById("chart2"));
			var that = this;
			var fontColor = "#30eee9";
			this.closeDoorOption = {
				backgroundColor: "transparent",
				grid: {
					left: "5%",
					right: "2%",
					top: "10%",
					bottom: "15%",
				},
				tooltip: {
					show: false,
					trigger: "axis",
					axisPointer: {
						type: "shadow",
						lineStyle: {
							color: "#57617B",
						},
					},
				},
				xAxis: {
					type: "category",
					axisLine: {
						show: true,
						lineStyle: {
							color: "#000000",
						},
					},
					boundaryGap: false, // 显示间距设置为false
					axisTick: {
						show: false,
						alignWithLabel: true,
						lineStyle: {
							color: "#000000",
						},
					},
					axisLabel: {
						fontSize: 16,
						show: true,
					},
					data: that.closeDoorSpeedX,
				},
				yAxis: {
					name: "速度",
					type: "value",
					min: 0,
					max: Math.max(...this.closeDoorSpeed),
					axisLine: {
						show: true,
						lineStyle: {
							color: "#000000",
						},
					},
					splitLine: {
						show: true,
						lineStyle: {
							type: "dotted",
							color: "#000000",
						},
					},
					axisTick: {
						show: true,
					},
					axisLabel: {
						fontSize: 16,
					},
					boundaryGap: ["20%", "20%"],
				},
				series: [{
					name: "",
					type: "line",
					stack: "总量",
					smooth: true,
					symbol: "none",
					showSymbol: false,
					symbolSize: 8,
					lineStyle: {
						color: "#FFD700",
						width: 5,
					},
					markPoint: {
						itemStyle: {
							color: "red",
						},
					},
					data: this.closeDoorSpeed,
				},],
			};
			this.curveChart2.setOption(this.closeDoorOption);
			window.addEventListener("resize", () => {
				this.curveChart2.resize();
			});
		},
	},
};
</script>
<style scoped>
.selectDoor>>>.el-select {
	width: 100%;
}

.bg-top {
	/* height: 44vh; */
	background-color: #fff;
	border-radius: 10px;
	padding: 1.8vh 1.5vw 0.9vh 1.5vw;
}

.bg-bottom {
	/* height: 44vh; */
	margin-top: 1.85vh;
	background-color: #fff;
	border-radius: 10px;
	padding: 1.8vh 1.5vw 0.9vh 1.5vw;
}

.baseHeader {
	margin: 0;
	font-size: 18px;
	font-weight: 500;
	color: rgba(46, 48, 51, 1);
}

.leftBox {
	height: 37.4vh;
}

.rightBox {
	/* height: 37.4vh; */
	/* padding: 1.29vh 7.39vw 0 7.39vw; */
}

.chart {
	width: 100%;
	height: 100%;
}

.rightBox>>>.el-input__inner {
	/* width: 10.4vw; */
}

.leftcontent {
	width: 40%;
}

.leftcontent1 {
	margin-left: 10%;
}

@media screen and (max-width: 1580px) {
	.leftcontent1 {
		width: 50%;
	}
}

@media screen and (max-width: 1280px) {
	.leftcontent1 {
		width: 50%;
	}
}
</style>
